<HTML> 
<HEAD> 
	<TITLE>3rd Party ROBOTC Drivers</TITLE> 
<link href="tabs.css" rel="stylesheet" type="text/css"/> 
<link href="doxygen.css" rel="stylesheet" type="text/css"/> 
</HEAD> 
 
<BODY bgcolor="#ffffff" link="#000000" vlink="#000000"> 
<table width="100%" bgcolor="navy" cellspacing=0 cellpadding=1 border=0> 
<tr><td><table width="100%" bgcolor="#EEEEDD" cellspacing=0 cellpadding=3 border=0> 
<tr> 
    <td width="33%" align="left"> <img src="images/LOGO_NXT.gif" width=266 height=44 border="0" alt="Mindstorms"></td> 
    <td><b><font size="+3" color="navy">3rd Party ROBOTC Drivers</font></b></td> 
    <td align="right"> <img src="images/logo.png" width=44 height=44 border="0" alt="RobotC"></td>     
</tr> 
  <tr bgcolor="#cccc99" align="right"> 
          <td colspan=3> <font face="arial" size="-1"> [<a href=main.html>Home</a>] [<a target=_top href="https://sourceforge.net/projects/rdpartyrobotcdr/">Download</a>] [<a target=_top href="http://apps.sourceforge.net/mantisbt/rdpartyrobotcdr/my_view_page.php">Submit a bug/suggestion</a>]  [<a target=_top href="http://www.robotc.net/forums/">ROBOTC Forums</a>] [<a target=_top href="http://botbench.com">Blog</a>] [<a target=_top href="http://sourceforge.net/donate/index.php?group_id=257238">Support this project</a>]</font> </td> 
</tr> 
</table></td></tr> 
</table> 
<!-- Generated by Doxygen 1.7.2 -->
<div class="header">
  <div class="headertitle">
<h1>firgelli-linearact-test1.c</h1>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="comment">/*</span>
<span class="comment"> * $Id: firgelli-linearact-test1.c 133 2013-03-10 15:15:38Z xander $</span>
<span class="comment"> */</span>
<span class="comment"></span>
<span class="comment">/**</span>
<span class="comment"> * firgelli-linearact.h provides an API for the Firgelli Linear Actuator.  This program</span>
<span class="comment"> * demonstrates how to use that API.</span>
<span class="comment"> *</span>
<span class="comment"> * Changelog:</span>
<span class="comment"> * - 0.1: Initial release</span>
<span class="comment"> *</span>
<span class="comment"> * TODO:</span>
<span class="comment"> * - Add ramping support (being worked on, has a few bugs)</span>
<span class="comment"> *</span>
<span class="comment"> * Credits:</span>
<span class="comment"> * - Big thanks to Firgelli for providing me with a Linear Actuator to play with!</span>
<span class="comment"> *</span>
<span class="comment"> * License: You may use this code as you wish, provided you give credit where it&#39;s due.</span>
<span class="comment"> *</span>
<span class="comment"> * THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER. </span>
<span class="comment"></span>
<span class="comment"> * Xander Soldaat (xander_at_botbench.com)</span>
<span class="comment"> * 15 february 2010</span>
<span class="comment"> * version 0.1</span>
<span class="comment"> */</span>

<span class="preprocessor">#include &quot;<a class="code" href="firgelli-linearact_8h.html" title="Firgelli Linear Actuator driver.">drivers/firgelli-linearact.h</a>&quot;</span>

task main () {
  tMotor testMotor = motorA;

  PlaySound(soundBeepBeep);
  nxtDisplayBigTextLine(3, <span class="stringliteral">&quot;Retract&quot;</span>);
  <a name="a0"></a><a class="code" href="group__firgelli.html#ga9e27c20f6b889a07dfc4f6df8cc2b593">FLACretractLA</a>(testMotor, 100);
  <span class="keywordflow">while</span>(!<a name="a1"></a><a class="code" href="group__firgelli.html#gae29e139d329f2cf694d3c93be1f9452d">isDone</a>(testMotor)) wait1Msec(50);
  wait1Msec(200);
  nMotorEncoder[testMotor] = 0;
  wait1Msec(1000);

  PlaySound(soundBeepBeep);
  eraseDisplay();
  nxtDisplayBigTextLine(1, <span class="stringliteral">&quot;Extend&quot;</span>);
  nxtDisplayTextLine(3, <span class="stringliteral">&quot;ticks:  40&quot;</span>);
  nxtDisplayTextLine(4, <span class="stringliteral">&quot;speed:  50&quot;</span>);
  <a name="a2"></a><a class="code" href="group__firgelli.html#ga16d5a7d593e3ed43d553925be5e783d7">FLACextendLA</a>(testMotor, 50, 40);
  <span class="keywordflow">while</span>(!<a class="code" href="group__firgelli.html#gae29e139d329f2cf694d3c93be1f9452d">isDone</a>(testMotor)) wait1Msec(50);
  <span class="keywordflow">if</span> (<a name="a3"></a><a class="code" href="group__firgelli.html#ga7225cff05b727f1eb504039160fa6abc">isStalled</a>(testMotor))
    nxtDisplayTextLine(7, <span class="stringliteral">&quot;STALLED&quot;</span>);
  wait1Msec(1000);

  PlaySound(soundBeepBeep);
  eraseDisplay();
  nxtDisplayBigTextLine(1, <span class="stringliteral">&quot;Extend&quot;</span>);
  nxtDisplayTextLine(3, <span class="stringliteral">&quot;ticks: 100&quot;</span>);
  nxtDisplayTextLine(4, <span class="stringliteral">&quot;speed:  80&quot;</span>);
  <a class="code" href="group__firgelli.html#ga16d5a7d593e3ed43d553925be5e783d7">FLACextendLA</a>(testMotor, 80, 100);
  <span class="keywordflow">while</span>(!<a class="code" href="group__firgelli.html#gae29e139d329f2cf694d3c93be1f9452d">isDone</a>(testMotor)) wait1Msec(50);
  <span class="keywordflow">if</span> (<a class="code" href="group__firgelli.html#ga7225cff05b727f1eb504039160fa6abc">isStalled</a>(testMotor))
    nxtDisplayTextLine(7, <span class="stringliteral">&quot;STALLED&quot;</span>);
  wait1Msec(1000);
  eraseDisplay();

  PlaySound(soundBeepBeep);
  nxtDisplayBigTextLine(1, <span class="stringliteral">&quot;Retract&quot;</span>);
  nxtDisplayTextLine(3, <span class="stringliteral">&quot;ticks: 120&quot;</span>);
  nxtDisplayTextLine(4, <span class="stringliteral">&quot;speed: 100&quot;</span>);
  <a name="a4"></a><a class="code" href="group__firgelli.html#ga086fbbabdb08a88b4c888c32c788cf83">FLACtretractLA</a>(testMotor, 100, 120);
  <span class="keywordflow">while</span>(!<a class="code" href="group__firgelli.html#gae29e139d329f2cf694d3c93be1f9452d">isDone</a>(testMotor)) wait1Msec(50);
  <span class="keywordflow">if</span> (<a class="code" href="group__firgelli.html#ga7225cff05b727f1eb504039160fa6abc">isStalled</a>(testMotor))
    nxtDisplayTextLine(7, <span class="stringliteral">&quot;STALLED&quot;</span>);
  wait1Msec(1000);

  PlaySound(soundBeepBeep);
  nxtDisplayBigTextLine(1, <span class="stringliteral">&quot;Retract&quot;</span>);
  nxtDisplayTextLine(3, <span class="stringliteral">&quot;ticks:  20&quot;</span>);
  nxtDisplayTextLine(4, <span class="stringliteral">&quot;speed: 100&quot;</span>);
  <a class="code" href="group__firgelli.html#ga086fbbabdb08a88b4c888c32c788cf83">FLACtretractLA</a>(testMotor, 100, 20);
  <span class="keywordflow">while</span>(!<a class="code" href="group__firgelli.html#gae29e139d329f2cf694d3c93be1f9452d">isDone</a>(testMotor)) wait1Msec(50);
  <span class="keywordflow">if</span> (<a class="code" href="group__firgelli.html#ga7225cff05b727f1eb504039160fa6abc">isStalled</a>(testMotor))
    nxtDisplayTextLine(7, <span class="stringliteral">&quot;STALLED&quot;</span>);
  wait1Msec(1000);

  PlaySound(soundBeepBeep);
  eraseDisplay();
  nxtDisplayBigTextLine(1, <span class="stringliteral">&quot;Done&quot;</span>);
  wait1Msec(2000);
}

<span class="comment">/*</span>
<span class="comment"> * $Id: firgelli-linearact-test1.c 133 2013-03-10 15:15:38Z xander $</span>
<span class="comment"> */</span>
</pre></div> </div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Wed Mar 13 2013 19:56:42 for ROBOTC Drivers by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
</body>
</html>
